#pragma once
#include <iostream>
#include <vector>

namespace mian_yang
{
    template <size_t N>
    class bitset
    {
    public:
        bitset()
        {
            bits.resize((N / 32) + 1, 0);
            std::cout << N / 32 << std::endl;
        }

        bool set(size_t x)
        {
            int i = x / 32;
            int j = x % 32;
            bits[i] |= (1 << j);
            return true;
        }

        bool reset(size_t x)
        {
            int i = x / 32;
            int j = x % 32;
            bits[i] &= ~(1 << j);
            return true;
        }

        bool test(size_t x)
        {
            int i = x / 32;
            int j = x % 32;
            return bits[i] & (1 << j);
        }

        std::vector<int> bits;
    };

    template <size_t N>
    class dbitset
    {
    public:
        void set(size_t x)
        {
            if (bt1.test(x) == false && bt2.test(x) == false)
                bt2.set(x);
            else if (bt1.test(x) == false && bt2.test(x) == true)
            {
                bt1.set(x);
                bt2.reset(x);
            }
            else if (bt1.test(x) == true && bt2.test(x) == false)
                bt2.set(x);
        }

        void reset(size_t x)
        {
            if (bt1.test(x) == true && bt2.test(x) == true)
                bt2.reset(x);
            else if (bt1.test(x) == false && bt2.test(x) == true)
            {
                bt2.reset(x);
            }
            else if (bt1.test(x) == true && bt2.test(x) == false)
            {
                bt1.reset(x);
                bt2.set(x);
            }
        }

        bool test(size_t x)
        {
            if (bt1.test(x) == true)
                return true;
            else
                return false;
        }

    private:
        mian_yang::bitset<N> bt1;
        mian_yang::bitset<N> bt2;
    };
}